from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.db import transaction

from forms import CaipsRequestForm

@transaction.commit_on_success
def index(request):
    if request.method == 'POST':
        form = CaipsRequestForm(data=request.POST)
        if form.is_valid():
            return HttpResponseRedirect(reverse("caips.core.views.thnx_req"))
    else:
        form = CaipsRequestForm()
        
    return render_to_response("index.html", {'title': 'Welcome', 'form': form},
                              context_instance=RequestContext(request))

def whyneed(request):
    return render_to_response("whyneed.html", {'title': 'Why do you need CAIPS'})

def webest(request):
    return render_to_response("webest.html", {'title': 'We are best'})

def contact(request):
    return render_to_response("contact.html", {'title': 'Contact us'})

def thnx_req(request):
    return render_to_response("thanks_request.html", {'title': 'Thank you'})

def thnx_pay(request):
    return render_to_response("thanks_payment.html", {'title': 'Thank you'})
